<template>
    <div>
        <el-dialog :before-close="handleClose" width="30%" title="查看CFP余额" :visible.sync="CfpDialog">
            <el-form :model="form">
                <el-form-item label="查询日期" label-width="80px">
                    <el-date-picker v-model="form.time" value-format="yyyy-MM-dd" type="date" placeholder="选择日期">
                    </el-date-picker>
                    <el-button :loading="loading" @click="submit" style="margin-left: 20px;" size="medium"
                        type="primary">查询</el-button>
                    <div style="color: red;">注:查询的是当天23:59:59的余额</div>
                </el-form-item>
                <el-form-item label="当天用户CFP余额为：" label-width="170px">
                    <span style="font-size: 30px;">{{ totalAmount }}</span>
                </el-form-item>
            </el-form>
        </el-dialog>
    </div>
</template>

<script>
import { getuserCFPApi } from '@/api/appuser/userList'
export default {
    props: {
        CfpDialog: {
            type: Boolean,
            default: false,
        },
        userid: {
            type: String,
            default: '',
        },
    },
    data() {
        return {
            form: {
                time: '',
            },
            totalAmount: "",
            loading: false,
        }
    },
    methods: {
        async submit() {
            this.loading = true
            const time = this.form.time + ' 23:59:59';
            const res = await getuserCFPApi({
                userId: this.userid,
                createTime: time,
            })
            console.log(time);
            this.totalAmount = res.totalAmount
            this.loading = false
        },
        handleClose() {
            this.form = {
                time: '',
            }
            this.totalAmount = ""
            this.$emit('update:CfpDialog', false)
        }
    },
}
</script>

<style></style>